<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Advanced Hotkey Features - Mouse and Keyboard Shortcuts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="static/theme.css" rel="stylesheet" type="text/css" />
<script src="static/content.js" type="text/javascript"></script>
</head>

<body>
<h1>Advanced Hotkey Features</h1>

<p><u>Some of the easiest keys to reach</u> on the keyboard are also the least frequently used. Make these keys do something useful! For example, if you rarely use the right ALT key, make it perform the action you do most often:</p>
<pre>RAlt::
MsgBox You pressed the right ALT key.
return</pre>
<p>You can even do the above without losing Right-ALT's native function by assigning Right-ALT to be a &quot;prefix&quot; for at least one other hotkey. In the below example, Right-ALT has become a prefix, which automatically allows it to modify <strong>all</strong> other keys as it normally would. But if you press and release Right-Alt without having used it to modify another key, its hotkey action (above) will take effect immediately:</p>
<pre>RAlt &amp; j::AltTab</pre>
<p>&nbsp;</p>
<p><u>Don't be limited to using only CTRL, ALT, SHIFT, and WIN</u> as modifiers; you can combine <strong>any</strong> two keys or mouse buttons to form a custom hotkey. For example: Hold down Numpad0 and press Numpad1 to launch a hotkey (syntax: Numpad0 &amp; Numpad1::); hold down CapsLock and press another key, or click a mouse button (syntax: CapsLock &amp; RButton::). In this case, the CapsLock key's state (on or off) is not changed when it is used to launch the hotkey. For details, see <a href="Hotkeys.htm#combo">custom combinations of keys</a>.</p>
<p>&nbsp;</p>
<p><u><a name="AltTab"></a>Convert the mouse wheel</u> (or any other keys of your choice) into a complete substitute for Alt-Tab. Click the wheel to show or hide the menu, and turn it to navigate through the menu. The wheel will still function normally whenever the Alt-Tab menu isn't visible. Syntax:</p>
<pre>MButton::AltTabMenu
WheelDown::AltTab
WheelUp::ShiftAltTab</pre>
<p>&nbsp;</p>
<p><u>Make a keyboard key <strong>become</strong> a mouse button</u>, or have an action repeated continuously while you're holding down a key or mouse button. See the <a href="misc/Remap.htm#RemapMouse">remapping page</a> for examples.</p>
<p>&nbsp;</p>
<p><u>Make your hotkeys context-sensitive</u>: Have your easiest-to-reach hotkeys perform an action appropriate to the type of window you're working with. In the following example, the right Control key performs a different action depending on whether Notepad or Calculator is the active window:</p>
<pre>#IfWinActive ahk_class Notepad
RControl::WinMenuSelectItem, , , File, Save  <em>; Save the current file in Notepad.</em>

#IfWinActive Calculator
RControl::Send, ^c!{tab}^v  <em>; Copy the Calculator's result into the previously active window.</em></pre>
<p>See <a href="commands/_IfWinActive.htm">#IfWinActive</a> for details.</p>
<p>&nbsp;</p>
<p><u>Hot-strings: Define abbreviations that expand as you type them</u>. No special training or scripting experience is needed.  For example, a script containing the following lines would expand ceo, cfo, and btw wherever you type them:</p>
<pre>::ceo::Chief Executive Officer
::cfo::Chief Financial Officer
::btw::by the way</pre>
<p><a href="Hotstrings.htm">(more details)</a><br>
</p>
<p>&nbsp;</p>
<p><strong><u>Of special interest for gaming:</u></strong></p>
<ul>
  <li>Reduce wear &amp; tear on your fingers by using virtually <a href="KeyList.htm">any key</a> as a hotkey, including single letters, arrow keys, Numpad keys, and even the modifier keys themselves (CTRL/ALT/WIN/SHIFT).</li>
  <li>Create mouse hotkeys, including the mouse wheel button (MButton) and the turning of the wheel up/down or left/right (WheelUp, WheelDown, WheelLeft, and WheelRight). You can also combine a keyboard key with a mouse button. For example, control-right-button would be expressed as <code>^RButton::</code>.</li>
  <li>Create &quot;pass-through&quot; hotkeys. For example, the left mouse button can trigger a hotkey action even while the click itself is being sent  into the game normally (syntax: <code>~LButton::</code>).</li>
  <li>Use commands such as <a href="commands/PixelSearch.htm">PixelSearch</a>, <a href="commands/PixelGetColor.htm">PixelGetColor</a>, and <a href="commands/ImageSearch.htm">ImageSearch</a> to automate game actions.</li>
  <li>Have the option of using the <a href="commands/_UseHook.htm">keyboard hook</a> to implement hotkeys, which might be more responsive than other hotkey methods while the CPU is under load in a game. The hook might also be able to override any restrictions a game may have about which keys can be &quot;mapped&quot; to game actions.</li>
</ul>
<p>See the <a href="Hotkeys.htm">Hotkeys</a> section for more detailed information.</p>
</body>
</html>
